#!/bin/bash

export LD_LIBRARY_PATH="/vdb1/convert:$LD_LIBRARY_PATH"

while [ "1" == "1" ]
do
	for hdq_path in `find /vdb1/ -type d -name "518_*"`
	do
		echo -e "\033[41;37m ===== 搜索到的活动区有：  ${hdq_path}  ==== \033[0m"
		SRC_PATH="${hdq_path}/app/roadshowcenter_app/wwwroot/upload/media/*.mp4"
		[ ! -d ${hdq_path}/app/roadshowcenter_app/wwwroot/upload/media/output/ ] && mkdir -p ${hdq_path}/app/roadshowcenter_app/wwwroot/upload/media/output/
		DST_PATH="${hdq_path}/app/roadshowcenter_app/wwwroot/upload/media/output/"
		echo -e "\033[41;37m ===== 转换前目录为：  $SRC_PATH  ==== \033[0m"
		echo -e "\033[41;37m ===== 转换后目录为：  $DST_PATH  ==== \033[0m"
		
		
		for  fn in $SRC_PATH
		do
			echo -e "\033[41;37m =====需要转码的视频为：  $fn ==== \033[0m" 
                        if test -f $fn
                        then
                              /vdb1/convert/ffmpeg  -i $fn -acodec libfaac -vcodec h264 -f mp4 $DST_PATH$(basename $fn .mp4).m
                              mv $DST_PATH$(basename $fn .mp4).m $DST_PATH${fn##*/}
                              rm -rf $fn
                        fi
                        echo -e "\033[41;37m =====转码完成的视频：  $fn ==== \033[0m"
			echo -e "=======================  华丽的分割线  ====================================== \n"
		done
		sleep 3
	done
done

